package com.hw.one.dam2.controller;

import com.hw.one.core.result.MsgResult;
import com.hw.one.ext.util.UserUtil;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * 不同用户显示不同站点
 * <p>
 * Copyright 2017 汉威.智慧环保事业部
 * Created by 毛超然 on 2017/7/10 0009.
 */

@RestController
@RequestMapping(value = "userSite")
public class UserSiteController {

    @RequestMapping(value = "findUserSiteTypeData", method = RequestMethod.GET)
    public MsgResult findCountGridRegionData(Model model, HttpServletRequest request) {
        Set<String> resultSet = new HashSet<>();
        Map<String, Object> departmentMap = UserUtil.getDepartment();
        if (null != departmentMap) {
            Object siteTypes = departmentMap.get("siteType");
            if (null != siteTypes) {
                String[] siteTypeStrs = siteTypes.toString().split(",");
                for (String siteType : siteTypeStrs) {
                    if ("001".equals(siteType)) {
                        resultSet.add("nationalSite");
                        resultSet.add("allNationalSite");
                        resultSet.add("allAirSite");
                        continue;
                    }
                    if ("002".equals(siteType)) {
                        resultSet.add("provinceSite");
                        resultSet.add("allNationalSite");
                        resultSet.add("allAirSite");
                        continue;
                    }
                    if ("003".equals(siteType)) {
                        resultSet.add("citySite");
                        resultSet.add("allAirSite");
                        continue;
                    }
                    if ("004".equals(siteType)) {
                        resultSet.add("smallAirSite");
                        resultSet.add("allAirSite");
                        continue;
                    }
                    if ("101".equals(siteType)) {
                        resultSet.add("industrySite");
                        resultSet.add("allPollutionSite");
                        continue;
                    }
                    if ("102".equals(siteType)) {
                        resultSet.add("raiseDustSite");
                        resultSet.add("allPollutionSite");
                        continue;
                    }
                    if ("103".equals(siteType)) {
                        resultSet.add("lampblackSite");
                        resultSet.add("allPollutionSite");
                        continue;
                    }
                    if ("104".equals(siteType)) {
                        resultSet.add("sprayBoothSite");
                        resultSet.add("allPollutionSite");
                        continue;
                    }
                    if ("105".equals(siteType)) {
                        resultSet.add("gasStationSite");
                        resultSet.add("allPollutionSite");
                        continue;
                    }
                    if ("201".equals(siteType)) {
                        resultSet.add("waterPollutionSite");
                        resultSet.add("allPollutionSite");
                        continue;
                    }
                    if ("006".equals(siteType) || "007".equals(siteType) || "008".equals(siteType) || "009".equals(siteType) || "010".equals(siteType) || "011".equals(siteType)) {
                        resultSet.add("waterSurfaceSite");
                        continue;
                    }
                }
            }
        }

        return MsgResult.okResult(resultSet);
    }
}
